#include <stdio.h>
#include <string.h>
#include <float.h>

void p1() {
    char fistName[20], lastName[20];
    printf("please enter your first name and last name:");
    scanf("%s%s", fistName, lastName);
    printf("Hello %s %s\n", fistName, lastName);
}

void p2() {
    char name[20];
    printf("enter your name:");
    scanf("%s", name);
    printf("\"%s\"\n", name);
    printf("\"%20s\"\n", name);
    printf("\"%-20s\"\n", name);
    printf("\"%*s\"\n", strlen(name) + 3, name);
}

void p3() {
    float number;
    printf("enter a float number:");
    scanf("%f", &number);
    printf("a the input is %.2f or %.1e\n", number, number);
    printf("a the input is %.3f or %.3e", number, number);
}

void p4() {
    char name[20];
    float feets;
    printf("enter your name:");
    scanf("%s", name);
    printf("enter your feets:");
    scanf("%f", &feets);
    printf("%s,you are %.3f feet tall", name, feets);
}

void p5() {
    float megabits, megabytes;
    printf("enter download speed and file size:");
    scanf("%f%f", &megabits, &megabytes);
    float time = megabits / 8 / megabytes;
    printf("At %.2f megabits per second,a file of %.2f megabytes downloads in %.2f seconds:", megabits, megabytes,
           time);
}

void p6() {
    char firstName[20], lastName[20];
    printf("enter your full name:");
    scanf("%s%s", firstName, lastName);
    int lenFirstName = strlen(firstName);
    int lenLastName = strlen(lastName);
    printf("%s %s\n", firstName, lastName);
    printf("%*d %*d", lenFirstName, lenFirstName, lenLastName, lenLastName);
    printf("%-*d %-*d", lenFirstName, lenFirstName, lenLastName, lenLastName);
}

void p7() {
    float f = 1.0f / 3.0f;
    double d = 1.0 / 3.0;
    printf("float----.6f:%.6f,.12f:%.12f,.16f:%.16f\n", f, f, f);
    printf("double----.6f:%.6f,.12f:%.12f,.16f:%.16f\n", d, d, d);
    printf("float有效位数-FLT_DIG:%d,double有效位数-DBL_DIG:%d", FLT_DIG, DBL_DIG);
}

#define J_S 3.785
#define Y_Q 1.609
#define SCALE_VALUE 100
void p8() {
    float lichengKm,haoyouliangShen,jialun,yinli,haoyousudu1,haoyousudu2;
    printf("输入走了多少千米消耗多少汽油：");
    scanf("%f%f",&lichengKm,&haoyouliangShen);
    jialun = haoyouliangShen/J_S;
    yinli = lichengKm/Y_Q;
    haoyousudu1 = yinli/jialun;
    haoyousudu2 = haoyousudu1*(Y_Q/J_S)/SCALE_VALUE;
    printf("英里/加仑：%.4f\n",haoyousudu1);
    printf("升/100公里：%.4f\n",haoyousudu2);
}

int main() {
//    p1();
//    p2.c();
//    p3();
//    p4();
    //   p5();
//       p6();
//       p7();
    p8();
}